// ---------无人机拓展----------------
export const uav_fly_init = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav=fly()\n';
    return code;
}

export const uav_getTicks_sec = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav.getTicks_sec()';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_getTimer = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav.getTimer()';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_clearTimer = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav.clearTimer()';
    return code;
}

export const uav_sleep = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var sleep = generator.valueToCode(this, 'sleep', generator.ORDER_ATOMIC);
    var code = 'fly_uav.sleep(' + sleep + ')\n';
    return code;
}

export const uav_setAutoDelay = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var key = generator.valueToCode(this, 'key', generator.ORDER_ATOMIC);
    var code = 'fly_uav.setAutoDelay(' + key + ')\n';
    return code;
}

export const uav_fly_takeOff = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var high = generator.valueToCode(this, 'high', generator.ORDER_ATOMIC);
    var code = 'fly_uav.takeOff(' + id + ',' + high + ')\n';
    return code;
}

export const uav_fly_flyMode = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.flyMode(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_xySpeed = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var speed = generator.valueToCode(this, 'speed', generator.ORDER_ATOMIC);
    var code = 'fly_uav.xySpeed(' + id + ',' + speed + ')\n';
    return code;
}

export const uav_fly_zSpeed = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var speed = generator.valueToCode(this, 'speed', generator.ORDER_ATOMIC);
    var code = 'fly_uav.zSpeed(' + id + ',' + speed + ')\n';
    return code;
}

export const uav_fly_moveCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var distance = generator.valueToCode(this, 'distance', generator.ORDER_ATOMIC);
    var code = 'fly_uav.moveCtrl(' + id + ',' + mode + ',' + distance + ')\n';
    return code;
}

export const uav_fly_moveSearchDot = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var distance = generator.valueToCode(this, 'distance', generator.ORDER_ATOMIC);
    var code = 'fly_uav.moveSearchDot(' + id + ',' + mode + ',' + distance + ')\n';
    return code;
}

export const uav_fly_moveSearchBlob = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var distance = generator.valueToCode(this, 'distance', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.moveSearchBlob(' + id + ',' + mode + ',' + distance + ',' + LIST + ')\n';
    return code;
}

export const uav_fly_moveSearchTag = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var distance = generator.valueToCode(this, 'distance', generator.ORDER_ATOMIC);
    var tagID = generator.valueToCode(this, 'tagID', generator.ORDER_ATOMIC);
    var code = 'fly_uav.moveSearchTag(' + id + ',' + mode + ',' + distance + ',' + tagID + ')\n';
    return code;
}

export const uav_fly_moveFollowTag = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var distance = generator.valueToCode(this, 'distance', generator.ORDER_ATOMIC);
    var tagID = generator.valueToCode(this, 'tagID', generator.ORDER_ATOMIC);
    var code = 'fly_uav.moveFollowTag(' + id + ',' + mode + ',' + distance + ',' + tagID + ')\n';
    return code;
}

export const uav_fly_goTo = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.goTo(' + id + ',' + LIST + ')\n';
    return code;
}

export const uav_fly_goToTag = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var tagID = generator.valueToCode(this, 'tagID', generator.ORDER_ATOMIC);
    var high = generator.valueToCode(this, 'high', generator.ORDER_ATOMIC);
    var code = 'fly_uav.goToTag(' + id + ',' + tagID + ',' + high + ')\n';
    return code;
}

export const uav_fly_rotation = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var angle = generator.valueToCode(this, 'angle', generator.ORDER_ATOMIC);
    var code = 'fly_uav.rotation(' + id + ',' + angle + ')\n';
    return code;
}

export const uav_fly_flyHigh = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var high = generator.valueToCode(this, 'high', generator.ORDER_ATOMIC);
    var code = 'fly_uav.flyHigh(' + id + ',' + high + ')\n';
    return code;
}

export const uav_fly_flipCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var cir = generator.valueToCode(this, 'cir', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.flipCtrl(' + id + ',' + mode + ',' + cir + ')\n';
    return code;
}

export const uav_fly_ledCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.ledCtrl(' + id + ',' + mode + ',' + LIST + ')\n';
    return code;
}

export const uav_fly_closeLed = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var code = 'fly_uav.closeLed(' + id + ')\n';
    return code;
}

export const uav_fly_shootCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.shootCtrl(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_magnetCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.magnetCtrl(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_servoCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var angle = generator.valueToCode(this, 'angle', generator.ORDER_ATOMIC);
    var code = 'fly_uav.servoCtrl(' + id + ',' + angle + ')\n';
    return code;
}

//---------Ctrl--------

export const uav_fly_mvCheckMode = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.mvCheckMode(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_mvCheckAprilTag = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var tagID = generator.valueToCode(this, 'tagID', generator.ORDER_ATOMIC);
    var code = 'fly_uav.mvCheckAprilTag(' + id + ',' + tagID + ')\n';
    return code;
}

export const uav_fly_mvCheckBlob = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.mvCheckBlob(' + id + ',' + mode + ',' + LIST + ')\n';
    return code;
}

export const uav_fly_getFlySensor = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.getFlySensor(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_fly_lockDir = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.lockDir(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_flyCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.flyCtrl(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_photographMode = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.photographMode(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_fly_roleCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var data = generator.valueToCode(this, 'data', generator.ORDER_ATOMIC);
    var code = 'fly_uav.roleCtrl(' + id + ',' + data + ')\n';
    return code;
}

export const uav_fly_getRoleNews = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.getRoleNews(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_fly_clearRoleNews = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var code = 'fly_uav.clearRoleNews(' + id + ')\n';
    return code;
}

export const uav_fly_move = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.move(' + id + ',' + mode + ',' + LIST + ')\n';
    return code;
}

export const uav_setCenterOffset = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.setCenterOffset(' + id + ',' + LIST + ')\n';
    return code;
}

export const uav_setLocation = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.setLocation(' + id + ',' + LIST + ')\n';
    return code;
}

export const uav_setTagDistance = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var high = generator.valueToCode(this, 'high', generator.ORDER_ATOMIC);
    var code = 'fly_uav.setTagDistance(' + id + ',' + high + ')\n';
    return code;
}

export const uav_cameraDeg = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var ange = generator.valueToCode(this, 'ange', generator.ORDER_ATOMIC);
    var code = 'fly_uav.cameraDeg(' + id + ',' + ange + ')\n';
    return code;
}

export const uav_irSend = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var LIST = generator.valueToCode(this, 'LIST', generator.ORDER_ATOMIC);
    var code = 'fly_uav.irSend(' + id + ',' + mode + ',' + LIST + ')\n';
    return code;
}

export const uav_showStr = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var data = generator.valueToCode(this, 'data', generator.ORDER_ATOMIC);
    var xx = generator.valueToCode(this, 'x', generator.ORDER_ATOMIC);
    var yy = generator.valueToCode(this, 'y', generator.ORDER_ATOMIC);
    var num = generator.valueToCode(this, 'num', generator.ORDER_ATOMIC);
    var code = 'fly_uav.showStr(' + id + ',' + xx + ',' + yy + ',str(' + data + '),' + num + ')\n';
    return code;
}

export const uav_showCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.showCtrl(' + id + ',' + mode + ')\n';
    return code;
}

export const uav_photoOk = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav.photoOk()';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_getKeyPress = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var code = 'fly_uav.getKeyPress(' + id + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_isMvCheck = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.isMvCheck(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_isMvCheckLine = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.isMvCheckLine(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_getObsDistance = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.getObsDistance(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_getBlobResult = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.getBlobResult(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_switchCtrl = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var key = generator.valueToCode(this, 'key', generator.ORDER_ATOMIC);
    var code = 'fly_uav.switchCtrl(' + id + ',' + key + ')\n';
    return code;
}

export const uav_getScaleWeight = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var code = 'fly_uav.getScaleWeight(' + id + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_getShootResult = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var id = generator.valueToCode(this, 'id', generator.ORDER_ATOMIC);
    var mode = this.getFieldValue('mode');
    var code = 'fly_uav.getShootResult(' + id + ',' + mode + ')';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_snapshot = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = 'fly_uav.snapshot()';
    return [code, generator.ORDER_ATOMIC];
}

export const uav_display = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var img = generator.valueToCode(this, 'img', generator.ORDER_ATOMIC);
    var code = "fly_uav.display(" + img + ")\n";
    return code;
}

export const uav_end = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var code = "fly_uav.sleep(-1)\n";
    return code;
}

export const uav_while = function (_, generator) {
    generator.definitions_['from helloFly import fly'] = 'from helloFly import fly';
    var bool = generator.valueToCode(this, 'BOOL', generator.ORDER_NONE);
    var code = 'while not(' + bool + '):\n    fly_uav.sleep(0.01)\n';
    return code;
}